<form method="post">
    <ul class="colonnes">
    <?php $first=true; ?>
    <?php foreach($profiles as $profile){ ?>
        <li>
            <h3>
                <button class="suppr" name="delete" value="CLPR_<?= $profile->CLPR_NUMID ?>">x</button>
                <input type="text" name="CLPR_LIBEL-<?= $profile->CLPR_NUMID ?>" value="<?= $profile->CLPR_LIBEL ?>"/>
            </h3>
            <input type="text" class="comment" name="CLPR_DETAI-<?= $profile->CLPR_NUMID ?>" value="<?= $profile->CLPR_DETAI ?>" />
            <table border="1" class="liste">
                <thead>
                    <tr>
                        <th>Age</th>
                        <?php foreach($periodes as $periode){ ?>
                        <td>
                            <?php if($first): ?>
                            <button class="suppr" name="delete" value="PERI_<?= $periode->PERI_NUMID ?>">x</button>
                            <input type="text" name="PERI_LIBEL-<?= $periode->PERI_NUMID ?>" value="<?= $periode->PERI_LIBEL ?>"/>
                            <?php else: ?>
                            <?= $periode->PERI_LIBEL ?>
                            <?php endif; ?>
                        </td>
                        <?php } ?>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach($ages as $age){ ?>
                    <tr>
                        <th>
                            <?php if($first): ?>
                            <button class="suppr" name="delete" value="CLAG_<?= $age->CLAG_NUMID ?>">x</button>
                            <input type="text" name="CLAG_LIBEL-<?= $age->CLAG_NUMID ?>" value="<?= $age->CLAG_LIBEL ?>"/>
                            <?php else: ?>
                            <?= $age->CLAG_LIBEL ?>
                            <?php endif; ?>
                        </th>
                        <?php foreach($periodes as $periode){ ?>
                        <?php $id1=$profile->CLPR_NUMID; $id2=$age->CLAG_NUMID; $id3=$periode->PERI_NUMID; ?>
                        <td>
                            <input type="number" name="prix_<?php echo($id1.'_'.$id2.'_'.$id3); ?>" value="<?= $tarifs[$id1][$id2][$id3] ?>" step="0.05"/> €
                        </td>
                        <?php } ?>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>
        </li>
        <?php $first=false; ?>
    <?php } ?>
    </ul>
    <button name="action" value="save">Enregistrer</button>
</form>